<%@ page language="java" contentType="text/html; charset=UTF-8" pageEncoding="UTF-8"%>
<%String path = request.getContextPath();%>
<%@ taglib uri="/WEB-INF/tld/c.tld" prefix="c" %> 
<!DOCTYPE html>
<html lang="zh-CN">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<title>优惠券发放管理 列表</title>
<jsp:include page="../../import.jsp" flush="true"/>
</head>
<body class="iframeBody">
<div class="Wrapper">
<div class="searchArea">
    <form id="searchBar">
        <div class="fieldset1 clearFix">

			<div class="FXBR">
				<div class="fieldBox">
					<div class="label">客户姓名</div>
					<div class="field">
						<input name="cstNm" id="cstNm" type="text" class="ui-textbox" value="" ligerui="width: 160">
					</div>
					<div class="label">发放时间</div>
					<div class="field">
						<input name="issueStrDate" id="issueStrDate" type="text" class="ui-datepicker" value="" validate="{required:true, maxlength:500}">
					</div>
					<div class="label">至</div>
					<div class="field">
						<input name="issueEndDate" id="issueEndDate" type="text" class="ui-datepicker" value="" validate="{required:true, maxlength:500}">
					</div>
					<div class="label">优惠券状态</div>
					<div class="field">
						<select name="personalStatus" id="personalStatus">
							<option value="">--全部--</option>
							<option value="1">弹窗推送</option>
							<option value="2">领取成功</option>
							<option value="3">借款使用</option>
							<option value="4">还款使用</option>
						</select>
					</div>
				</div>
			</div>

            <div class="clearFix"></div>
	            <div class="btnsBox formBtns notRight">
					<span id="clearBtn" onclick="clearBtn();" class="sq-button-round">清空</span>
					<span id="searchBtn" onclick="searchBtn();" class="sq-button-round">查询</span>
				</div>
        	</div>
        </form>
    </div>
</div>

<div id="dataGrid" class="sq-grid"></div>
</div>

<script type="text/javascript">
	var grid = null;
	$(function () {
		initForm();
		initGrid();
	});

	//初始化表单
	function initForm(){
		$("#searchBar").ligerForm();
	}

	//查询按钮事件
	function searchBtn(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		for (name in data){
			grid.setParm(name,data[name]);
		};
		grid.reload();
	}

	//查询参数
	function getSearchParams(){
		var form = new liger.get("searchBar");
		var data = form.getData();
		return data;
	}

	//初始化列表
	function initGrid(){
		$("#dataGrid").ligerGrid({
	    	url: '<%=path%>/mcr/mcrCouponRed/initList.do',
	    	method : 'post',
	    	isSingleCheck: false,
	    	parms:getSearchParams(),
	        columns: [
				{ display: '编号', name: 'id', width: 150, enabledSort:true},
	            { display: '客户姓名', name: 'cstNm', width: 150, enabledSort:true },
	            { display: '用户ID', name: 'usrId', width: 150, enabledSort:true },
	            { display: '客户ID', name: 'cstId', width: 150, enabledSort:true },
	            { display: '手机号', name: 'mp', width: 150, enabledSort:true },
	            { display: '优惠券ID', name: 'cpId', width: 150, enabledSort:true},
	            { display: '优惠券名称', name: 'coupon.cpNm', width: 150, enabledSort:true},
	            { display: '有效期', name: 'coupon.expireShow', width: 150, enabledSort:true},
	            { display: '发放时间', name: 'issueTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '发放成功时间', name: 'issueSucTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '使用时间', name: 'useTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '生效时间', name: 'effectTm', width: 150, enabledSort:true, render:renderDate},
	            { display: '优惠券状态', name: 'personalStatus', width: 150, enabledSort:true,
					render:function(rowData){
						if(rowData.personalStatus=="0"){
							return "未开启";
						}else if (rowData.personalStatus=="1"){
							return "弹窗推送";
						}else if (rowData.personalStatus=="2"){
							return "领取成功";
						}else if (rowData.personalStatus=="3"){
							return "借款使用";
						}else {
							return "还款使用";
						}
					}
				},
	            { display: '是否过期', name: 'isExpired', width: 150, enabledSort:true,
					render:function(rowData){
						if (rowData.isExpired=="1") {
							return "已过期";
						} else {
							return "未过期";
						}
					}
				},
	            { display: '是否有效', name: 'isValid', width: 150, enabledSort:true,
					render:function(rowData){
						if (rowData.isValid=="1") {
							return "有效";
						} else {
							return "失效";
						}
					}
	            }
	        ],
	        pageSize:10,
	        root:'rows',
	        record:'total',
	        hideLoadButton : true,
	        width: '100%',
	        height:'100%',
	        heightDiff:-2,
	        checkbox:true,
	        rownumbers:true
	    });
	    grid = liger.get("dataGrid");
	    grid.setHeight(100);
	}

	//格式化时间
	function renderDate(rowdata, index, value){
		var dateStr = "";
		if(null != value){
			var date = new Date(value);
			dateStr = DateUtils.formatDate(date, DateUtils.YYYY_MM_DDHHMMSS);
		}
		return dateStr;
	}

	//清空按钮事件
	function clearBtn(){
		$("#resetBtn").click();  //重置 input-text
		var form = new liger.get("searchBar");
		form.setData({  //重置select等特殊表单
			"cstNm":"",
			"issueStrDate":"",
			"issueEndDate":"",
			"personalStatus":"",
			"isExpired":"",
			"isValid":""
		});
	}

</script>

</body>
</html>